package com.example.spring.redis.controller;

import com.example.spring.redis.common.config.CacheManagerConfiguration;
import com.example.spring.redis.common.constants.CommonConstants;
import com.example.spring.redis.common.model.UserModel;
import com.example.spring.redis.service.UserManagerService;
import com.google.common.collect.Lists;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

import static com.example.spring.redis.common.constants.CommonConstants.GLOBAL_CACHE_HOLDER;

/**
 * <p>
 *
 * </p>
 *
 * @author Ashe
 * @version V1.0.0
 * @date 2019/12/27 0027$ 11:09$
 * @modificationHistory=========================逻辑或功能性重大变更记录
 * @modify By: {修改人} 2019/12/27 0027$
 * @modify reason: {方法名}:{原因}
 * ...
 * @since V1.0.0
 */
@RestController
@Slf4j
public class UserRestController {

    @Resource
    private UserManagerService userManagerService;


    /**
     * 添加人员
     *
     * @param group
     * @param user
     * @return
     */
    @RequestMapping("/person/addition")
    public int add(String group, String user) {
        return userManagerService.add(group, user);
    }

    @RequestMapping("/person/group/find")
    public List<UserModel> findByName(String groupName) {
        return userManagerService.findByGroupName(groupName);
    }

    @RequestMapping("/person/group/reload")
    public String reloadByName(String userName) {
        userManagerService.reloadByGroupName(userName);
        return "success";
    }
}

